#include "RedSoldierPhysics.h"




void RedSoldierPhysics::_updateBulletContainer()
{
	if (_armyData->bulletContainer->checkCanFire() && !_armyData->isDead) {
		if (_armyData->bulletContainer->fire(_armyData->getRect()->X, _armyData->getRect()->Y, 0, _armyData->targetRect, new RedSoldierBulletBehavior())) {
			_armyData->sprites->currentSprite->Next();
		}
	}
	_armyData->bulletContainer->update(0);
}

void RedSoldierPhysics::_setToDead(int actiondata)
{
	_armyData->canInteract = false;
	_armyData->delayForDead = _DATA_DELAY_FOR_DEAD;
}

void RedSoldierPhysics::updateBeforeDead()
{
	_armyData->getRect()->X += 1;
	_armyData->getRect()->Y += 3;
	_armyData->delayForDead--;
	if (_armyData->delayForDead <= 0) {
		_armyData->isDead = true;
	}
}

RedSoldierPhysics::RedSoldierPhysics(ArmyData* data) : GunPhysics(data)
{
	data->getRect()->Height -= 20;
}

void RedSoldierPhysics::update(long timetick)
{
	if(_armyData->delayForDead > 0) {
		updateBeforeDead();
	} else {
		GunPhysics::update(timetick);
	}
}
